<style lang="less" scoped>
</style>
<template>
    <base-model
        @model-close="staffClose"
        @model-ok="staffOk"
        title="员工信息修改"
        :value="value"
        :loading="loading"
        @input="updateshow">
        <!--<Form :model="addUserForm" :label-width="120" ref="addUserForm" :rules="rule">
            <FormItem label="用户名：" prop="name">
                <base-input v-model="addUserForm.name" placeholder="请输入6-16位用户名"></base-input>
            </FormItem>
            <FormItem label="密码：" prop="password">
                <base-input v-model="addUserForm.password" type="password" placeholder="请输入6-16位密码"></base-input>
            </FormItem>
            <FormItem label="确认密码：" prop="passwordcheck">
                <base-input v-model="addUserForm.passwordcheck" type="password" placeholder="请再输入一次密码"></base-input>
            </FormItem>
        </Form>-->
        <Form :model="editUserForm" :label-width="120" ref="editUserForm" :rules="rule">
            <FormItem label="员工姓名：" prop="realname">
                <Input v-model="editUserForm.realname" placeholder="请输入员工姓名" :maxlength="16" style="width: 200px"></Input>
            </FormItem>
            <FormItem label="联系方式：" prop="phone">
                <Input v-model="editUserForm.phone" placeholder="请输入员工联系方式" :maxlength="16" style="width: 200px"></Input>
            </FormItem>
            <FormItem label="邮箱：" prop="email">
                <Input v-model="editUserForm.email" placeholder="请输入员工邮箱" :maxlength="16" style="width: 200px"></Input>
            </FormItem>
            <FormItem label="岗位：" prop="post">
                <Input v-model="editUserForm.post" placeholder="请输入员工岗位" :maxlength="16" style="width: 200px"></Input>
            </FormItem>
            <FormItem label="备注：" prop="remark">
                <Input v-model="editUserForm.remark" placeholder="请输入备注信息" type="textarea" :maxlength="80" style="width: 80%"></Input>
            </FormItem>
        </Form>
    </base-model>
</template>
<script>
    export default {
        name: 'edituser',
        props: {
            value: {
                type: Boolean,
                default: false
            },
            current: {
                default: {
                    realname: '',
                    phone: '',
                    email: '',
                    post: '',
                    user: '',
                    password: '',
                    hours: '',
                    remark: '',
                    state: 1
                }
            }
        },
        data () {
            return {
                loading: true,
                rule: {
                    name: this.rule.noNull('用户名不能为空')
                }
            }
        },
        computed: {
            editUserForm () {
                if (this.current == null) {
                    return {
                        realname: '',
                        phone: '',
                        email: '',
                        post: '',
                        user: '',
                        password: '',
                        hours: '',
                        remark: '',
                        state: 1
                    }
                } else {
                    return JSON.parse(JSON.stringify(this.current))
                }
            }
        },
        methods: {
            updateshow (show) {
                this.$emit('input', show)
            },
            reset () {
                // this.$refs['editUserForm'].resetFields();
                // this.editUserForm = JSON.parse(JSON.stringify(this.current))
            },
            staffClose () {
                this.reset()
            },
            setuserdata (data) {
                this.$emit('setuserdata', data)
            },
            setmodel (state) {
                this.$emit('setmodel', state)
            },
            staffOk () {
                this.$refs['editUserForm'].validate((valid) => {
                    if (valid) {
                        this.http.editUser(this, this.editUserForm)
                    }
                })
            }
        },
        components: {
        },
        mounted: function () {
        }
    };
</script>
